package com.sgzn.sgpay.service.tcp.model;

import com.sgzn.sgpay.model.request.SgsBaseRequest;
import com.sgzn.sgpay.service.tcp.SgTcpProtocolHead;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Pattern;

/**
 * Created by xxjs-gd-llf
 * DATETIME:2018/4/11 23:18
 * Description: 服务器远程消费充值（服务器上分）
 */
@Setter
@Getter
public class TcpConsumeRequest extends SgsBaseRequest{

    /**
     * 请求流水号
     */
    @NotBlank
    private String reqSeq;

    /**
     * 设备ID号
     */
    @NotBlank
    private String deviceId;

    /**
     * 交易金额【单位元】
     */
    @NotBlank(message="交易金额不能为空")
    @Pattern(regexp = "^[1-9][0-9]{0,16}$")
    private String amount;

    private String beginCode;

    private String commandCode ;

    private String checkSumCode;

   private String endCode;

    @Override
    public String toString(){
        //根据协议规范重载toString方法
        return    beginCode+ SgTcpProtocolHead.TCP_SEND_SEPERATOR+
                commandCode+ SgTcpProtocolHead.TCP_SEND_SEPERATOR+
                deviceId + SgTcpProtocolHead.TCP_SEND_SEPERATOR+
                reqSeq + SgTcpProtocolHead.TCP_SEND_SEPERATOR+
                amount+ SgTcpProtocolHead.TCP_SEND_SEPERATOR+
                checkSumCode+ SgTcpProtocolHead.TCP_SEND_SEPERATOR+
                endCode;
    }

}
